Skip to content

Update fontsource integration according with the documentation#482

Closed
cedric07 wants to merge 1 commit intomasterfrom
fix/fontsource-doc
Closed

Update fontsource integration according with the documentation#482
cedric07 wants to merge 1 commit intomasterfrom
fix/fontsource-doc

Conversation

@cedric07
Copy link
Copy Markdown
Contributor

@cedric07 cedric07 commented Apr 7, 2026

Mise à jour de l'intégration de font source via l'utilitaire recommandé par la documentation. Font source a évolué entre temps.

Summary by Sourcery

Update font loading to use the recommended @fontsource-utils SCSS mixins for defining font faces.

New Features:

  • Integrate @fontsource-utils SCSS utilities for managing font-face declarations.

Enhancements:

  • Refine SCSS font integration examples and implementation to align with current @fontsource documentation.

Build:

  • Add @fontsource-utils/scss, add, and yarn as package.json dependencies.

Note

Medium Risk
Medium risk: updates font-face generation and adds new runtime dependencies, which can subtly change compiled CSS/font loading and bundling output.

Overview
Switches Fontsource SCSS integration to the recommended @fontsource-utils/scss faces mixin, passing font $metadata instead of calling the font package’s faces directly.

Updates dependencies/lockfile to include @fontsource-utils/scss (and adds add and yarn to dependencies), which may affect install/bundle behavior.

Reviewed by Cursor Bugbot for commit f399a33. Bugbot is set up for automated code reviews on this repo. Configure here.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai bot commented Apr 7, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Updates the project’s fontsource integration to follow the new recommended SCSS utility-based API, wiring Poppins font usage through the shared fontsource mixins and adding the corresponding dependency along with lockfile updates.

Class diagram for SCSS modules in updated fontsource integration

classDiagram
  class FontsourceUtilsScss {
    <<module>>
    +faces(metadata, weights, styles, axes)
  }

  class FontsourcePoppinsScss {
    <<module>>
    +$metadata
    +faces(weights, styles)
  }

  class FontsScss {
    <<scss_base>>
    +use_fontsource_utils()
    +use_poppins_mixins()
    +include_poppins_faces_normal()
    +include_poppins_faces_italic()
  }

  FontsScss ..> FontsourceUtilsScss : uses
  FontsScss ..> FontsourcePoppinsScss : uses
  FontsourceUtilsScss ..> FontsourcePoppinsScss : reads metadata
Loading

Flow diagram for updated fontsource SCSS integration

flowchart LR
  A[Install dependencies via package.json] --> B[at fontsource-utils/scss installed]
  A --> C[at fontsource/poppins installed]

  B --> D[SCSS file _fonts.scss]
  C --> D

  subgraph NodeModules
    B
    C
  end

  D --> E[at use fontsource mixins]
  D --> F[at use Poppins mixins]

  E --> G[at include fontsource.faces with Poppins.$metadata normal]
  E --> H[at include fontsource.faces with Poppins.$metadata italic]

  G --> I[Generated at font-face rules for Poppins normal]
  H --> J[Generated at font-face rules for Poppins italic]

  I --> K[Compiled CSS output]
  J --> K
Loading

File-Level Changes

Change Details Files
Switch font-face declarations to use the new @fontsource-utils SCSS mixins with font metadata.
  • Update documentation comments to instruct installing the @fontsource-utils/scss package alongside individual font packages.
  • Replace direct @use of font-specific mixins for both classic and variable fonts with a shared @use of the fontsource-utils mixins plus the font-specific mixins.
  • Change example and concrete @include calls to use fontsource.faces with the font package’s $metadata, passing weights or axes as arguments.
src/scss/03-base/_fonts.scss
Add the fontsource utilities and additional dependencies to the project and refresh the lockfile.
  • Add @fontsource-utils/scss as a runtime dependency in package.json.
  • Introduce new dependencies add and yarn in package.json alongside existing ones.
  • Regenerate yarn.lock to capture the new/updated dependencies.
package.json
yarn.lock

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 2 issues, and left some high level feedback:

  • Using hardcoded ../../../node_modules/... paths in the SCSS @use statements is brittle; consider relying on package resolution (e.g. @use '@fontsource-utils/scss/src/mixins') or your bundler’s include paths instead.
  • The addition of add and yarn to dependencies looks unrelated to the fontsource change and may be unnecessary runtime dependencies; double-check whether they can be omitted or moved to devDependencies.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Using hardcoded `../../../node_modules/...` paths in the SCSS `@use` statements is brittle; consider relying on package resolution (e.g. `@use '@fontsource-utils/scss/src/mixins'`) or your bundler’s include paths instead.
- The addition of `add` and `yarn` to `dependencies` looks unrelated to the fontsource change and may be unnecessary runtime dependencies; double-check whether they can be omitted or moved to devDependencies.

## Individual Comments

### Comment 1
<location path="package.json" line_range="21" />
<code_context>
   "dependencies": {
+    "@fontsource-utils/scss": "^0.2.2",
     "@fontsource/poppins": "^5.0.5",
+    "add": "^2.0.6",
     "lazysizes": "^5.3.2",
-    "oneloop.js": "^5.2.1"
</code_context>
<issue_to_address>
**🚨 suggestion (security):** Reconsider introducing the generic `add` package as a dependency unless it’s clearly needed.

This package is very small and commonly used only in examples. Adding it as a runtime dependency increases your dependency surface (and potential vulnerability exposure) for limited gain. If it’s only needed for build tooling, consider moving it to `devDependencies`, or omitting it entirely if it’s not essential.

Suggested implementation:

```
    "@fontsource-utils/scss": "^0.2.2",
    "@fontsource/poppins": "^5.0.5",
    "lazysizes": "^5.3.2",

```

1. If the `add` package is actually required for build tooling (e.g., used in scripts or config), reintroduce it under `"devDependencies"` instead of `"dependencies"`.
2. Run `yarn install` or `npm install` after updating `package.json` to sync the lockfile (`yarn.lock` or `package-lock.json`) and include that in the PR as well.
</issue_to_address>

### Comment 2
<location path="package.json" line_range="24" />
<code_context>
     "lazysizes": "^5.3.2",
-    "oneloop.js": "^5.2.1"
+    "oneloop.js": "^5.2.1",
+    "yarn": "^1.22.22"
   },
   "devDependencies": {
</code_context>
<issue_to_address>
**🚨 issue (security):** Avoid listing `yarn` as an application dependency.

Putting `yarn` in `dependencies` installs it in production even though it’s only a dev tool, increasing install time and attack surface. Please remove it from `dependencies`; only use `devDependencies` (or external documentation) if you truly need to call it explicitly.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

"dependencies": {
"@fontsource-utils/scss": "^0.2.2",
"@fontsource/poppins": "^5.0.5",
"add": "^2.0.6",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 suggestion (security): Reconsider introducing the generic add package as a dependency unless it’s clearly needed.

This package is very small and commonly used only in examples. Adding it as a runtime dependency increases your dependency surface (and potential vulnerability exposure) for limited gain. If it’s only needed for build tooling, consider moving it to devDependencies, or omitting it entirely if it’s not essential.

Suggested implementation:

    "@fontsource-utils/scss": "^0.2.2",
    "@fontsource/poppins": "^5.0.5",
    "lazysizes": "^5.3.2",

  1. If the add package is actually required for build tooling (e.g., used in scripts or config), reintroduce it under "devDependencies" instead of "dependencies".
  2. Run yarn install or npm install after updating package.json to sync the lockfile (yarn.lock or package-lock.json) and include that in the PR as well.

"lazysizes": "^5.3.2",
"oneloop.js": "^5.2.1"
"oneloop.js": "^5.2.1",
"yarn": "^1.22.22"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 issue (security): Avoid listing yarn as an application dependency.

Putting yarn in dependencies installs it in production even though it’s only a dev tool, increasing install time and attack surface. Please remove it from dependencies; only use devDependencies (or external documentation) if you truly need to call it explicitly.

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Accidental add and yarn packages committed as dependencies
    • Removed accidental add and yarn entries from dependencies and regenerated yarn.lock to fully drop both packages from the dependency graph.

Create PR

Or push these changes by commenting:

@cursor push a4a7ac7a89

This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.

Reviewed by Cursor Bugbot for commit f399a33. Configure here.

"lazysizes": "^5.3.2",
"oneloop.js": "^5.2.1"
"oneloop.js": "^5.2.1",
"yarn": "^1.22.22"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Accidental add and yarn packages committed as dependencies

Medium Severity

The "add": "^2.0.6" and "yarn": "^1.22.22" entries in dependencies are spurious packages accidentally introduced when installing @fontsource-utils/scss. The add package is an unrelated floating-point math library, and yarn is the package manager itself (already managed via packageManager and volta fields). Neither is imported or used anywhere in the project source code. These bloat the production dependency tree unnecessarily and could cause confusion or conflicts.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit f399a33. Configure here.

@cedric07 cedric07 closed this Apr 7, 2026
@cedric07 cedric07 deleted the fix/fontsource-doc branch April 7, 2026 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant